<?php
$config = bone::get_config('system');
if($config->sef)
{
	// 如果启用了搜索引擎优化， 则把网址按以下规则匹配
	// {controller}-{task}-{param_name}-{param_value}-{param_name}-{param_value}.html
	// 其中参数 {param_name}-{param_value} 值对不限数量
	
	$uri = $_SERVER['REQUEST_URI'];

	
	$start_pos = strripos($uri,'/')+1;
	/*
	if($start_pos>1)
	{
		header('location:/404.html');
		exit;
	}
	*/

	$end_pos = strripos($uri,'.');
	if($end_pos!==false && $end_pos>$start_pos)
	{
		$uri = substr($uri, $start_pos, $end_pos-$start_pos);
		$uri = explode('-', $uri);
		$len = count($uri);
		if($len>=2)
		{
			$_GET['controller'] = $_REQUEST['controller'] = array_shift($uri);
			$_GET['task'] = $_REQUEST['task'] = array_shift($uri);
			$len -= 2;
			if($len>0)
			{
				for($i=0; $i<$len; $i+=2)
				{
					$_GET[$uri[$i]] = $_REQUEST[$uri[$i]] = $uri[$i+1];
				}
			}
		}
	}
}
?>